home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Archive / Networking / OTTCPWillDial / TestOTTCPWillDial.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  2.0 KB  |  74 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        TestOTTCPWillDial.c
  3.  
  4.     Contains:    Trivial application to test OTTCPWillDial library.
  5.  
  6.     Written by:    Quinn "The Eskimo!"
  7.  
  8.     Copyright:    © 1998 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.     You may incorporate this sample code into your applications without
  13.     restriction, though the sample code has been provided "AS IS" and the
  14.     responsibility for its operation is 100% yours.  However, what you are
  15.     not permitted to do is to redistribute the source as "DSC Sample Code"
  16.     after having made changes. If you're going to re-distribute the source,
  17.     we require that you make it clear in the source that the code was
  18.     descended from Apple Sample Code, but that you've made changes.
  19. */
  20.  
  21. /////////////////////////////////////////////////////////////////
  22. // Pick up the standard C console stuff.
  23.  
  24. #import <stdio.h>
  25.  
  26. /////////////////////////////////////////////////////////////////
  27. // Pick up the OT API, just to call InitOpenTransport.
  28.  
  29. #import <OpenTransport.h>
  30.  
  31. /////////////////////////////////////////////////////////////////
  32. // Pick up the library prototypes.
  33.  
  34. #import "OTTCPWillDial.h"
  35.  
  36. /////////////////////////////////////////////////////////////////
  37.  
  38. extern void main(void)
  39. {
  40.     OSStatus err;
  41.     UInt32  willTCPDial;
  42.     
  43.     printf("TestOTTCPWillDial\n");
  44.     printf("-- A trivial program to test the OTTCPWillDial library.\n\n");
  45.     
  46.     err = InitOpenTransport();
  47.     
  48.     if (err == noErr) {
  49.         err = OTTCPWillDial(&willTCPDial);
  50.         
  51.         CloseOpenTransport();
  52.     }
  53.  
  54.     if (err == noErr) {
  55.         switch ( willTCPDial ) {
  56.             case kOTTCPDialUnknown:
  57.                 printf("We don't know whether opening a TCP endpoint will dial the modem.\n");
  58.                 break;
  59.             case kOTTCPDialTCPDisabled:
  60.                 printf("TCP/IP is disabled.\n");
  61.                 break;
  62.             case kOTTCPDialYes:
  63.                 printf("Opening a TCP endpoint will dial the modem.\n");
  64.                 break;
  65.             case kOTTCPDialNo:
  66.                 printf("Opening a TCP endpoint will not dial the modem.\n");
  67.                 break;
  68.         }
  69.     } else {
  70.         printf("Failed with error %ld.\n", err);
  71.     }
  72.     printf("Done.  Press command-Q to Quit.\n");
  73. }
  74.